<template>
    <div class="app-container">
      <div class="block">
        <el-row  :gutter="24">

          <el-col :span="4">
            <el-input v-model="listQuery.carNo" placeholder="车牌号后四位"></el-input>
          </el-col>
          <el-col :span="4">
            <el-select v-model="listQuery.communityId" placeholder="选择社区" @change="getCustsSearch">
              <el-option
                v-for="item in options.communityIds"
                :key="item.id"
                :label="item.name"
                :value="item.id">
              </el-option>
            </el-select>
          </el-col>
          <el-col :span="4">
            <el-select v-model="listQuery.custId" placeholder="选择客户"
                       filterable :filter-method="custFilterSearch" @change="change($event)">
              <el-option
                v-for="item in options.searchCustIds"
                :key="item.custId"
                :label="item.custName"
                :value="item.custId">
              </el-option>
            </el-select>
          </el-col>
          <el-col :span="8">
            <el-button type="success" icon="el-icon-search" @click.native="search">{{ $t('button.search') }}</el-button>
            <el-button type="primary" icon="el-icon-refresh" @click.native="reset">{{ $t('button.reset') }}</el-button>
          </el-col>
        </el-row>
        <br>
      </div>


        <div class="block">
            <el-row>
                <el-col :span="24">
                    <el-button type="success" icon="el-icon-plus" @click.native="add">{{ $t('button.add') }}</el-button>
                    <el-button type="primary" icon="el-icon-edit" @click.native="edit">{{ $t('button.edit') }}</el-button>
                    <el-button type="danger" icon="el-icon-delete" @click.native="remove">{{ $t('button.delete') }}</el-button>
                </el-col>
            </el-row>
        </div>


        <el-table :data="list" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row
                  @current-change="handleCurrentChange">
            <el-table-column label="序号" type="index" show-overflow-tooltip width="50" align="center">

            </el-table-column>
            <el-table-column label="车牌号" align="center">
              <template slot-scope="scope">
                {{scope.row.carNo}}
              </template>
            </el-table-column>
            <el-table-column label="客户" align="center">
                <template slot-scope="scope">
                    {{scope.row.custName}}
                </template>
            </el-table-column>
            <el-table-column label="社区" align="center">
                <template slot-scope="scope">
                    {{scope.row.communityName}}
                </template>
            </el-table-column>
            <el-table-column label="车架号" align="center">
                <template slot-scope="scope">
                    {{scope.row.vin}}
                </template>
            </el-table-column>
            <el-table-column label="注册日期" align="center">
                <template slot-scope="scope">
                    {{scope.row.registerDateStr}}
                </template>
            </el-table-column>
          <el-table-column label="新能源标识" align="center">
            <template slot-scope="scope">
              {{scope.row.electricFlagName}}
            </template>
          </el-table-column>
          <el-table-column label="品牌" align="center">
            <template slot-scope="scope">
              {{scope.row.carBrand}}
            </template>
          </el-table-column>
          <el-table-column label="型号" align="center">
            <template slot-scope="scope">
              {{scope.row.carModel}}
            </template>
          </el-table-column>
          <!--<el-table-column label="状态">
              <template slot-scope="scope">
                  {{scope.row.stateName}}
              </template>
          </el-table-column>-->
          <el-table-column label="状态" prop="stateName" align="center">
            <template slot-scope="scope">
              <span style="color:blue;" v-if="scope.row.state===1">{{scope.row.stateName}}</span>
              <span style="color:red;" v-if="scope.row.state===0">{{scope.row.stateName}}</span>
            </template>
          </el-table-column>
        </el-table>

        <el-pagination
                background
                layout="total, sizes, prev, pager, next, jumper"
                :page-sizes="[10, 20, 50, 100,500]"
                :page-size="listQuery.limit"
                :total="total"
                @size-change="changeSize"
                @current-change="fetchPage"
                @prev-click="fetchPrev"
                @next-click="fetchNext">
        </el-pagination>

        <el-dialog
                :title="formTitle"
                :visible.sync="formVisible"
                width="70%">
            <el-form ref="form" :model="form" :rules="rules" label-width="150px">
                <el-row>
                    <el-col :span="12">
                        <!--<el-form-item label="社区"  >
                            <el-input v-model="form.communityId" minlength=1></el-input>
                        </el-form-item>-->
                        <el-form-item label="社区" prop="communityId">
                          <el-select v-model="form.communityId" placeholder="请选择" @change="getCusts">
                            <el-option
                              v-for="item in options.communityIds"
                              :key="item.id"
                              :label="item.name"
                              :value="item.id">
                            </el-option>
                          </el-select>
                        </el-form-item>
                    </el-col>
                  <el-col :span="12">
                    <!--<el-form-item label="客户"  >
                      <el-input v-model="form.custId" minlength=1></el-input>
                    </el-form-item>-->
                    <el-form-item label="客户" prop="custId">
                      <el-select v-model="form.custId" placeholder="请选择"
                                 filterable :filter-method="custFilter">
                        <el-option
                          v-for="item in options.custIds"
                          :key="item.custId"
                          :label="item.custName"
                          :value="item.custId">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                    <el-col :span="12">
                        <el-form-item label="车牌号" prop="carNo">
                            <!--<el-input v-model="form.carNo" minlength=1></el-input>-->
                            <el-select v-model="form.carNo1"  placeholder="选" style="width:60px" @change="change($event)">
                              <el-option
                                v-for="item in options.area1"
                                :key="item.k"
                                :label="item.v"
                                :value="item.v">
                              </el-option>
                            </el-select>
                            <el-select v-model="form.carNo2"  placeholder="选" style="width:60px" @change="change($event)">
                              <el-option
                                v-for="item1 in options.area2"
                                :key="item1.v"
                                :label="item1.v"
                                :value="item1.v">
                              </el-option>
                            </el-select>
                            <span>·</span>
                            <el-input v-model="form.carNo3" minlength=1 style="width:140px" @input="change($event)"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="车架号"  >
                            <el-input v-model="form.vin" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="注册日期" prop="registerDate" >
                        <el-date-picker type="date" placeholder="选择日期" v-model="form.registerDate" style="width: 100%;">

                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="是否新能源" prop="electricFlag" >
                        <el-select v-model="form.electricFlag" placeholder="请选择">
                          <el-option
                            v-for="item in options.electricFlag"
                            :key="item.k"
                            :label="item.v"
                            :value="item.k">
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="品牌"  >
                        <el-input v-model="form.carBrand" minlength=1></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="型号"  >
                        <el-input v-model="form.carModel" minlength=1></el-input>
                      </el-form-item>
                    </el-col>
                    <!--<el-col :span="12">
                        <el-form-item label="状态"  >
                            <el-input v-model="form.state" minlength=1></el-input>
                        </el-form-item>
                    </el-col>-->
                </el-row>
                <el-form-item>
                    <el-button type="primary" @click="save">{{ $t('button.submit') }}</el-button>
                    <el-button @click.native="formVisible = false">{{ $t('button.cancel') }}</el-button>
                </el-form-item>

            </el-form>
        </el-dialog>
    </div>
</template>

<script src="./car_info.js"></script>


<style rel="stylesheet/scss" lang="scss" scoped>
    @import "src/styles/common.scss";
</style>

